package it.bifulco.luigi.motiondetection.prototype;

public class ImageCompareTest {

	/*
	 * The setParameters() accepts four parameters. - The number of vertical
	 * columns in the comparison grid. - The number of horizontal rows in the
	 * comparison grid. - A threshold value. If the difference in brightness
	 * exceeds this then the region is considered different. A stabilization
	 * factor. In future I will calculate this automatically since it is
	 * proportional to parameters 1 and 2. setDebugMode() is completely optional
	 * and only really usefull while designing your parameters.
	 * 
	 * After running compare(), match() will hold the result.
	 */
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		// Create a compare object specifying the 2 images for comparison.
		ImageCompare ic = new ImageCompare("test1.jpg", "test2.jpg");
		// Set the comparison parameters.
		// (num vertical regions, num horizontal regions, sensitivity,
		// stabilizer)
		ic.setParameters(10, 7, 1, 10);
		// Display some indication of the differences in the image.
		ic.setDebugMode(1);
		// Compare.
		ic.compare();
		// Display if these images are considered a match according to our
		// parameters.
		System.out.println("Match: " + ic.match());
		// If its not a match then write a file to show changed regions.
		if (!ic.match()) {
			ImageCompare.saveJPG(ic.getChangeIndicator(), "changes.jpg");
		}
		long end = System.currentTimeMillis();
		long diff = end - start;
		System.out.println("Time computation : " + diff);
	}

}
